from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db

from header import *
from footer import *
from toidi import *
from highscore_entry import *

class MainHandler(webapp.RequestHandler):

  def get(self):
      data = {}
      data['highscores'] = db.GqlQuery('SELECT * FROM Highscore_Entry ORDER BY score DESC')
      
      # self.response.out.write('Highscores: ' + data['highscores'])
      render_header(self.response, self.request, {'title': 'Highscore'})
      self.response.out.write(template.render(toidi_template('highscore'), data))
      render_footer(self.response, {})


def main():
  application = webapp.WSGIApplication([('/highscore', MainHandler)],
                                       debug=True)
  util.run_wsgi_app(application)


if __name__ == '__main__':
  main()
